﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class UserControls_CashflowLiquidity : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
      string id = Request.Params["id"];
      StockAnalysis analysis = new StockAnalysis();
      DataTable dt = analysis.GetCashflowLiquidityTable(id);
      gridviewCashflowLiquidity.DataSource = ConvertSubFigures.Convert(dt);
      gridviewCashflowLiquidity.DataBind();

      Graph g = new Graph();
      Dictionary<string, string[]> graphData = ConvertGraphData.Convert(dt);

      string[] year;
      string[] degreeOfLiquidity;
      string[] cashFlowFromOperatingActivities;
      string[] dividendPrShare;
      string[] dividendPrStockPrice;

      graphData.TryGetValue("year", out year);

      graphData.TryGetValue("degree_of_liquidity", out degreeOfLiquidity);
      graphDegreeOfLiquidity.InnerHtml = g.drawGraphOneAttributeWithFiveFigures(Dictionary.Translate("degree_of_liquidity"), "XAxis", Abbreviations.getAbbreviations("degree_of_liquidity"), degreeOfLiquidity, year, false, false, true);

      graphData.TryGetValue("cash_flow_from_operating_activities", out cashFlowFromOperatingActivities);
      graphCashFlowFromOperatingActivities.InnerHtml = g.drawGraphOneAttributeWithFiveFigures(Dictionary.Translate("cash_flow_from_operating_activities"), "XAxis", Abbreviations.getAbbreviations("cash_flow_from_operating_activities"), cashFlowFromOperatingActivities, year, false, false, false);

      graphData.TryGetValue("dividend_pr_share", out dividendPrShare);
      graphDividendPrShare.InnerHtml = g.drawGraphOneAttributeWithFiveFigures(Dictionary.Translate("dividend_pr_share"), "XAxis", Abbreviations.getAbbreviations("dividend_pr_share"), dividendPrShare, year, true, false, false);

      graphData.TryGetValue("dividend_pr_stock_price", out dividendPrStockPrice);
      graphDividendPrStockPrice.InnerHtml = g.drawGraphOneAttributeWithFiveFigures(Dictionary.Translate("dividend_pr_stock_price"), "XAxis", Abbreviations.getAbbreviations("dividend_pr_stock_price"), dividendPrStockPrice, year, true, true, false);
    }
}